#!/usr/bin/env bash

cd $(dirname $0)

ADDRESS='10.64.56.214:8120'
#ADDRESS='localhost:8080'
#ADDRESS='hot.hupu.com:80'
#ADDRESS='hot2.hupu.com:80'

if [[ -z $1 ]]
then
    paras+=" --data-urlencode cid=99999900" 
else
    paras+=" --data-urlencode cid=$1"
fi

if [[ -z $2 ]]
then
    paras+=" --data-urlencode is_first=0"
else
    paras+=" --data-urlencode is_first=$2"
fi
#paras+=" --data-urlencode topics="

JSON_FORMAT=$(cat <<EOF

import sys
import json
str=''
for line in sys.stdin:
    str+=line
print(json.dumps(json.loads(str), ensure_ascii=False, indent=4, sort_keys=True))

EOF
)

cmd="curl -v -G $paras $ADDRESS/buffer/hotlistbytopic"
echo $cmd
eval $cmd | python3 -c "$JSON_FORMAT"
